package com.bing.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author 徐
 * @version 1.0
 * 控制器:演示rest风格请求
 * 去掉@RestController注解，不返回json格式字符串
 * 就会去找试图解析器
 */
@Controller
public class MonsterController {

    //@RequestMapping(value = "/monster",method = RequestMethod.GET)
    @GetMapping("/monster")
    public String getMonster(){
        return "GET-查询妖怪";
    }

    //@RequestMapping(value = "/monster",method = RequestMethod.POST)
    @PostMapping("/monster")
    public String saveMonster(){
        return "Post-添加妖怪";
    }

    //@RequestMapping(value = "/monster",method = RequestMethod.PUT)
    @PutMapping("/monster")
    public String putMonster(){
        return "PUT-修改妖怪";
    }

    //@RequestMapping(value = "/monster",method = RequestMethod.DELETE)
    @DeleteMapping("/monster")
    public String delMonster(){
        return "DELETE-删除妖怪";
    }

    /**
     * 顺序1:先看controller有没有/hello[没有配置视图解析器的情况,配置就去视图解析器]
     * 2:如果没有就到视图解析器
     * 需要配置视图解析器:No mapping for GET /hello
     * @return
     */
    @RequestMapping("/go")
    public String go(){
        return "hello";
    }
}
